package baiduClub.schedule;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;

public class CheckActivity extends Activity{
	
	public static final String flag = "baiduClub.schedule.CheckActivity";
	private Button confirmButton = null;
	private Button cancelButton = null;
	private DatePicker datePicker = null;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.check_layout);
		
		cancelButton = (Button)findViewById(R.checkID.cancelButton);
		cancelButton.setOnClickListener(new CancelButtonListener());
		
		datePicker = (DatePicker)findViewById(R.checkID.datePicker);
		
		confirmButton = (Button)findViewById(R.checkID.confirmButton);
		confirmButton.setOnClickListener(new ConfirmButtonListener());
    }
	
	class CancelButtonListener implements OnClickListener
	{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			finish();
		}
		
	}
	
	class ConfirmButtonListener implements OnClickListener
	{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			MainActivity.yearOfSet = datePicker.getYear();
			MainActivity.monthOfSet = datePicker.getMonth();
			MainActivity.dayOfSet = datePicker.getDayOfMonth();
			
			finish();
			
//			Intent intent = new Intent();
//			intent.putExtra("year", datePicker.getYear());
//			intent.putExtra("month", datePicker.getMonth());
//			intent.putExtra("day", datePicker.getDayOfMonth());
//			intent.setClass(CheckActivity.this, MainActivity.class);
//			startActivityForResult(intent,0 );
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		if(requestCode ==0) 
		{
			setResult(RESULT_OK);
			finish();
		}
	}
	
	
}
